/*
  * Copyright (c) 2025 Huawei Device Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
    *
  * http://www.apache.org/licenses/LICENSE-2.0
    *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * */

// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from '@ohos/flatbuffers';

export class MessageEvent {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):MessageEvent {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsMessageEvent(bb:flatbuffers.ByteBuffer, obj?:MessageEvent):MessageEvent {
  return (obj || new MessageEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsMessageEvent(bb:flatbuffers.ByteBuffer, obj?:MessageEvent):MessageEvent {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new MessageEvent()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

text():string|null
text(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
text(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

priority():number {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}

static startMessageEvent(builder:flatbuffers.Builder) {
  builder.startObject(2);
}

static addText(builder:flatbuffers.Builder, textOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, textOffset, 0);
}

static addPriority(builder:flatbuffers.Builder, priority:number) {
  builder.addFieldInt32(1, priority, 0);
}

static endMessageEvent(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

static createMessageEvent(builder:flatbuffers.Builder, textOffset:flatbuffers.Offset, priority:number):flatbuffers.Offset {
  MessageEvent.startMessageEvent(builder);
  MessageEvent.addText(builder, textOffset);
  MessageEvent.addPriority(builder, priority);
  return MessageEvent.endMessageEvent(builder);
}
}
